﻿using FlipRunner.Physics;
using Microsoft.Xna.Framework;
using XnaPlus.Common;
using XnaPlus.Common.Visual;

namespace FlipRunner.Components
{
    public class Platform : DrawableGamePlusComponent, IPhysicsComponent
    {
        public Platform(GamePlus game) : base(game)
        {
        }

        #region IPhysicsComponent Members

        public new FlipRunnerGame Game
        {
            get { return base.Game as FlipRunnerGame; }
        }

        public ISize Size { get; set; }

        /// <summary>
        /// Top left corner
        /// </summary>
        public CartesianPoint Position { get; set; }

        public PositionAnchor Anchor
        {
            get { return PositionAnchor.TopLeft; }
        }

        #endregion

        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
            float elapsedSeconds = (float) gameTime.ElapsedGameTime.TotalSeconds;
            Position += elapsedSeconds*Game.PlatformVelocity;
        }

        public override void Draw(GameTime gameTime)
        {
            base.Draw(gameTime);
            var drawRect = this.GetDrawRectangle();
            Game.Drawer.DrawRectangle(drawRect, Color.Black);
        }
    }
}